<?php
class CopyrightsController extends AppController {

	var $name = 'Copyrights';
	var $helpers = array('Html', 'Form' );

	function index() {
		$this->Copyright->recursive = 0;
		$this->set('copyrights', $this->paginate());
	}

	function view($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid Copyright.');
			$this->redirect(array('action'=>'index'), null, true);
		}
		$this->set('copyright', $this->Copyright->read(null, $id));
	}

	function add() {
		if(!empty($this->data)) {
			$this->cleanUpFields();
			$this->Copyright->create();
			if($this->Copyright->save($this->data)) {
				$this->Session->setFlash('The Copyright has been saved');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Copyright could not be saved. Please, try again.');
			}
		}
	}

	function edit($id = null) {
		if(!$id && empty($this->data)) {
			$this->Session->setFlash('Invalid Copyright');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if(!empty($this->data)) {
			$this->cleanUpFields();
			if($this->Copyright->save($this->data)) {
				$this->Session->setFlash('The Copyright saved');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Copyright could not be saved. Please, try again.');
			}
		}
		if(empty($this->data)) {
			$this->data = $this->Copyright->read(null, $id);
		}
	}

	function delete($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid id for Copyright');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if($this->Copyright->del($id)) {
			$this->Session->setFlash('Copyright #'.$id.' deleted');
			$this->redirect(array('action'=>'index'), null, true);
		}
	}


	function admin_index() {
		$this->Copyright->recursive = 0;
		$this->set('copyrights', $this->paginate());
	}

	function admin_view($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid Copyright.');
			$this->redirect(array('action'=>'index'), null, true);
		}
		$this->set('copyright', $this->Copyright->read(null, $id));
	}

	function admin_add() {
		if(!empty($this->data)) {
			$this->cleanUpFields();
			$this->Copyright->create();
			if($this->Copyright->save($this->data)) {
				$this->Session->setFlash('The Copyright has been saved');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Copyright could not be saved. Please, try again.');
			}
		}
	}

	function admin_edit($id = null) {
		if(!$id && empty($this->data)) {
			$this->Session->setFlash('Invalid Copyright');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if(!empty($this->data)) {
			$this->cleanUpFields();
			if($this->Copyright->save($this->data)) {
				$this->Session->setFlash('The Copyright saved');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Copyright could not be saved. Please, try again.');
			}
		}
		if(empty($this->data)) {
			$this->data = $this->Copyright->read(null, $id);
		}
	}

	function admin_delete($id = null) {
		if(!$id) {
			$this->Session->setFlash('Invalid id for Copyright');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if($this->Copyright->del($id)) {
			$this->Session->setFlash('Copyright #'.$id.' deleted');
			$this->redirect(array('action'=>'index'), null, true);
		}
	}

}
?>